﻿using B.S.AuthCenter.Api.Read.Application.Command.MenuRole;
using B.S.AuthCenter.Api.Read.Application.Command.Roles;
using B.S.AuthCenter.Api.Read.DTOs;
using B.S.AuthCenter.Api.Read.DTOs.RoleMenu;
using B.S.AuthCenter.ErrorCount;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.AuthCenter.Api.Read.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class RolesController : ControllerBase
    {
        IMediator mediator;

        public RolesController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        [HttpGet]
        public Task<ApiResult<RolesDTO>> GetRole([FromQuery]GetRolesCommand request)
        {
            return mediator.Send(request);
        }
        [HttpPost]
        public Task<ApiResult<List<URDTO>>> GetUserRole(GetUserRoleCommand request)
        {
            return mediator.Send(request);
        }
        [HttpGet]
        public Task<ApiResult<List<RoleSelectDTO>>> GetRoleSelect([FromQuery]GetRoleSelectCommand request)
        {
            return mediator.Send(request);
        }
    }
}
